import json
import os
from pathlib import Path

def setup_mcp_config():
    # 获取当前脚本目录
    current_dir = Path(__file__).parent.absolute()
    main_py_path = current_dir / "main.py"
    
    # MCP 配置
    config = {
        "mcpServers": {
            "fastmcp-multi-service": {
                "command": "python",
                "args": [str(main_py_path)],
                "env": {}
            }
        }
    }
    
    # 确定配置文件路径
    if os.name == 'nt':  # Windows
        config_dir = Path(os.environ['APPDATA']) / "Claude"
    else:  # macOS/Linux
        config_dir = Path.home() / ".config" / "claude"
    
    config_dir.mkdir(parents=True, exist_ok=True)
    config_file = config_dir / "mcp_servers.json"
    
    # 写入配置文件
    with open(config_file, 'w', encoding='utf-8') as f:
        json.dump(config, f, indent=2, ensure_ascii=False)
    
    print(f"MCP 配置已写入: {config_file}")
    print("现在可以使用以下命令:")
    print("mcp call fastmcp-multi-service translate --msg 'Hello' --output_type 'json'")

if __name__ == "__main__":
    setup_mcp_config()